<div class="clearfix fix-float-left">
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
	'id'=>'user-form',
    'enableAjaxValidation'=>true,
    'enableClientValidation'=>true,
    'clientOptions'=>array(
        'validateOnSubmit'=>true,
    )
)); ?>
<div class="alert alert-info">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <p><strong>
        <span class="icon16  brocco-icon-mic"></span>
        <?php echo t('Fields with <span class="required">*</span> are required.','fcms'); ?>
    </strong></p>
</div>
    <div class="row-fluid">
        <div class="span6">

            <?php echo $form->textFieldRow($model,'username',array('class'=>'span5','maxlength'=>128)); ?>

            <?php echo $form->textFieldRow($model,'display_name',array('class'=>'span5','maxlength'=>255)); ?>

            <?php if(!$model->isNewRecord) echo $form->uneditableRow($model,'former_display_name'); ?>

            <?php if($model->isNewRecord) echo $form->passwordFieldRow($model,'password',array('class'=>'span5','maxlength'=>60)); ?>

            <?php if($model->isNewRecord) echo $form->passwordFieldRow($model,'repass',array('class'=>'span5','maxlength'=>60)); ?>

            <?php echo $form->textFieldRow($model,'email',array('class'=>'span5','maxlength'=>128)); ?>

            <?php
            echo $form->dropDownListRow($model, 'status', array(
            USER_ACTIVE=>t('Active'),
            USER_DEACTIVATE=>t('Deactivate'),
            USER_BANNED=>t('Banned'),
            ),array(
                'class'=>'span5',
            ));
            $disable = false;
            $style = '';
            if(isset($model->status) && $model->status != USER_BANNED) {
                $disable = true;
                $style = 'style="display: none;"';
            }
            ?>
            <div id="banned_time_ajax" <?php echo $style; ?> >
                <?php echo $form->datepickerRow($model,'time_ban',array('class'=>'span5','disabled'=>$disable)); ?>
            </div>
        </div>

        <div class="span6">

            <?php echo $form->datepickerRow($model,'birthday',array('class'=>'span5')); ?>

            <?php echo $form->dropDownListRow($model, 'gender', array(
            'male'=>t('Male'),
            'female'=>t('Female'),
            'unknow'=>t('Unknow'),
        ),array('class'=>'span5')); ?>

            <?php echo $form->textFieldRow($model,'location',array('class'=>'span5','maxlength'=>100)); ?>

            <?php echo $form->textFieldRow($model,'avatar',array('class'=>'span5','maxlength'=>255)); ?>

            <?php if(!$model->isNewRecord) echo $form->toggleButtonRow($model, 'confirmed',array('class'=>'nostyle')); ?>

            <?php echo $form->toggleButtonRow($model, 'email_site_news',array('class'=>'nostyle')); ?>

            <?php echo $form->toggleButtonRow($model, 'email_search_alert',array('class'=>'nostyle')); ?>

        </div>


    </div>
	<div class="form-actions">
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'submit',
			'type'=>'primary',
			'label'=>$model->isNewRecord ? t('Create','fuser') : t('Save','fuser'),
		));
        $this->widget('bootstrap.widgets.TbButton', array(
            'buttonType'=>'reset',
            'label'=>t('Reset','fuser'),
        ));
        ?>
	</div>

<?php $this->endWidget(); ?>
</div>
<?php
    $js = "$('#User_status').change(function(){
               var status = this.value;
               if(status == ".USER_BANNED.") {
                $('#User_time_ban').prop('disabled',false);
                $('#banned_time_ajax').show('slow','swing');
               } else {
                $('#banned_time_ajax').hide('slow','swing');
                $('#User_time_ban').prop('disabled',true);
               }
            });";
    cs()->registerScript('user_status_jqr',$js,CClientScript::POS_END);
?>